package com.yzf.demo.demo.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by 于占峰 on 2020/4/5/005.
 * <p>
 * 本地文件的输入输出流  ---> 拷贝文件
 */
public class FileInputStreamDemo {

    public static void main(String[] args) {
        try {
            //创建一个file输入流
            FileInputStream fileInputStream = new FileInputStream("G:/HellWorld.txt");
            try {
                int i = 0;
                i = fileInputStream.read();
                //System.out.println((char)i);//ASCII码 输出的是第一个字符
                //循环读取
                while ((i = fileInputStream.read()) != -1) {
                    System.out.print((char) i);
                }
                fileInputStream.close();//结束
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
